// $ANTLR : "AnasintC.g" -> "AnasintC.java"$

package pl.prac06;

import antlr.TokenBuffer;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.ANTLRException;
import antlr.LLkParser;
import antlr.Token;
import antlr.TokenStream;
import antlr.RecognitionException;
import antlr.NoViableAltException;
import antlr.MismatchedTokenException;
import antlr.SemanticException;
import antlr.ParserSharedInputState;
import antlr.collections.impl.BitSet;

public class AnasintC extends antlr.LLkParser       implements AnasintCTokenTypes
 {

protected AnasintC(TokenBuffer tokenBuf, int k) {
  super(tokenBuf,k);
  tokenNames = _tokenNames;
}

public AnasintC(TokenBuffer tokenBuf) {
  this(tokenBuf,3);
}

protected AnasintC(TokenStream lexer, int k) {
  super(lexer,k);
  tokenNames = _tokenNames;
}

public AnasintC(TokenStream lexer) {
  this(lexer,3);
}

public AnasintC(ParserSharedInputState state) {
  super(state,3);
  tokenNames = _tokenNames;
}

	public final void entrada() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case VOID:
		{
			function_def();
			break;
		}
		case INT:
		case CHAR:
		case FLOAT:
		case IF:
		case WHILE:
		case BREAK:
		case FOR:
		case ID:
		{
			action();
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void function_def() throws RecognitionException, TokenStreamException {
		
		
		match(VOID);
		match(ID);
		match(PARENTESIS_ABRIR);
		match(VOID);
		match(PARENTESIS_CERRAR);
		match(LLAVE_ABRIR);
		{
		int _cnt75=0;
		_loop75:
		do {
			if ((_tokenSet_0.member(LA(1)))) {
				action();
			}
			else {
				if ( _cnt75>=1 ) { break _loop75; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt75++;
		} while (true);
		}
		match(LLAVE_CERRAR);
	}
	
	public final void action() throws RecognitionException, TokenStreamException {
		
		
		{
		switch ( LA(1)) {
		case INT:
		case CHAR:
		case FLOAT:
		case BREAK:
		case ID:
		{
			linea_cod();
			match(SEMICOLON);
			break;
		}
		case IF:
		case WHILE:
		{
			loop_def();
			break;
		}
		case FOR:
		{
			loop_for();
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void linea_cod() throws RecognitionException, TokenStreamException {
		
		
		{
		switch ( LA(1)) {
		case BREAK:
		{
			match(BREAK);
			break;
		}
		case INT:
		case CHAR:
		case FLOAT:
		{
			declaration();
			break;
		}
		default:
			if ((LA(1)==ID) && (LA(2)==ASIGNACION)) {
				asignation();
			}
			else if ((LA(1)==ID) && (LA(2)==PARENTESIS_ABRIR)) {
				function_statement();
			}
		else {
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void loop_def() throws RecognitionException, TokenStreamException {
		
		
		{
		switch ( LA(1)) {
		case WHILE:
		{
			match(WHILE);
			break;
		}
		case IF:
		{
			match(IF);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		{
		switch ( LA(1)) {
		case NEGACION:
		{
			match(NEGACION);
			break;
		}
		case PARENTESIS_ABRIR:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(PARENTESIS_ABRIR);
		{
		if ((_tokenSet_1.member(LA(1))) && (_tokenSet_2.member(LA(2))) && (_tokenSet_3.member(LA(3)))) {
			{
			sentencia();
			}
			{
			_loop82:
			do {
				if ((LA(1)==OR||LA(1)==AND)) {
					anid_sentencia();
					sentencia();
				}
				else {
					break _loop82;
				}
				
			} while (true);
			}
		}
		else if ((LA(1)==PARENTESIS_ABRIR) && (_tokenSet_4.member(LA(2))) && (_tokenSet_5.member(LA(3)))) {
			{
			sentencia_cond();
			}
		}
		else {
			throw new NoViableAltException(LT(1), getFilename());
		}
		
		}
		match(PARENTESIS_CERRAR);
		match(LLAVE_ABRIR);
		{
		int _cnt85=0;
		_loop85:
		do {
			if ((_tokenSet_0.member(LA(1)))) {
				action();
			}
			else {
				if ( _cnt85>=1 ) { break _loop85; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt85++;
		} while (true);
		}
		match(LLAVE_CERRAR);
	}
	
	public final void loop_for() throws RecognitionException, TokenStreamException {
		
		
		match(FOR);
		match(PARENTESIS_ABRIR);
		asignation();
		match(SEMICOLON);
		{
		sentencia();
		}
		{
		_loop89:
		do {
			if ((LA(1)==OR||LA(1)==AND)) {
				anid_sentencia();
				sentencia();
			}
			else {
				break _loop89;
			}
			
		} while (true);
		}
		match(SEMICOLON);
		match(ID);
		{
		switch ( LA(1)) {
		case INC:
		{
			match(INC);
			break;
		}
		case DEC:
		{
			match(DEC);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(PARENTESIS_CERRAR);
		match(LLAVE_ABRIR);
		{
		int _cnt92=0;
		_loop92:
		do {
			if ((_tokenSet_0.member(LA(1)))) {
				action();
			}
			else {
				if ( _cnt92>=1 ) { break _loop92; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt92++;
		} while (true);
		}
		match(LLAVE_CERRAR);
	}
	
	public final void declaration() throws RecognitionException, TokenStreamException {
		
		
		{
		switch ( LA(1)) {
		case CHAR:
		{
			match(CHAR);
			break;
		}
		case INT:
		{
			match(INT);
			break;
		}
		case FLOAT:
		{
			match(FLOAT);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(ID);
		{
		_loop41:
		do {
			if ((LA(1)==COMA)) {
				match(COMA);
				match(ID);
			}
			else {
				break _loop41;
			}
			
		} while (true);
		}
	}
	
	public final void asignation() throws RecognitionException, TokenStreamException {
		
		
		match(ID);
		match(ASIGNACION);
		{
		if ((_tokenSet_4.member(LA(1))) && (LA(2)==NUM_INTEGER||LA(2)==SEMICOLON||LA(2)==PARENTESIS_ABRIR) && (_tokenSet_6.member(LA(3)))) {
			valor();
		}
		else if ((_tokenSet_4.member(LA(1))) && (_tokenSet_7.member(LA(2))) && (_tokenSet_8.member(LA(3)))) {
			expr();
		}
		else {
			throw new NoViableAltException(LT(1), getFilename());
		}
		
		}
	}
	
	public final void function_statement() throws RecognitionException, TokenStreamException {
		
		
		match(ID);
		match(PARENTESIS_ABRIR);
		{
		switch ( LA(1)) {
		case ID:
		case CADENA:
		{
			params_statement();
			break;
		}
		case PARENTESIS_CERRAR:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(PARENTESIS_CERRAR);
	}
	
	public final void valor() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case NUM_REAL:
		case NUM_INTEGER:
		case MENOS:
		{
			{
			switch ( LA(1)) {
			case NUM_INTEGER:
			case MENOS:
			{
				{
				switch ( LA(1)) {
				case MENOS:
				{
					match(MENOS);
					break;
				}
				case NUM_INTEGER:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				}
				}
				match(NUM_INTEGER);
				break;
			}
			case NUM_REAL:
			{
				match(NUM_REAL);
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			break;
		}
		case CADENA:
		{
			match(CADENA);
			break;
		}
		case ID:
		{
			function_statement();
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void expr() throws RecognitionException, TokenStreamException {
		
		
		{
		if ((LA(1)==MENOS) && (_tokenSet_4.member(LA(2))) && (_tokenSet_9.member(LA(3)))) {
			match(MENOS);
		}
		else if ((_tokenSet_4.member(LA(1))) && (_tokenSet_9.member(LA(2))) && (_tokenSet_10.member(LA(3)))) {
		}
		else {
			throw new NoViableAltException(LT(1), getFilename());
		}
		
		}
		{
		if ((LA(1)==ID) && (_tokenSet_11.member(LA(2))) && (_tokenSet_12.member(LA(3)))) {
			match(ID);
		}
		else if ((_tokenSet_4.member(LA(1))) && (_tokenSet_9.member(LA(2))) && (_tokenSet_10.member(LA(3)))) {
			valor();
		}
		else {
			throw new NoViableAltException(LT(1), getFilename());
		}
		
		}
		{
		_loop66:
		do {
			if (((LA(1) >= MAS && LA(1) <= DIV))) {
				operation();
				{
				if ((LA(1)==ID) && (_tokenSet_11.member(LA(2))) && (_tokenSet_12.member(LA(3)))) {
					match(ID);
				}
				else if ((_tokenSet_4.member(LA(1))) && (_tokenSet_9.member(LA(2))) && (_tokenSet_10.member(LA(3)))) {
					valor();
				}
				else {
					throw new NoViableAltException(LT(1), getFilename());
				}
				
				}
			}
			else {
				break _loop66;
			}
			
		} while (true);
		}
	}
	
	public final void params_statement() throws RecognitionException, TokenStreamException {
		
		
		param_stat();
		{
		_loop51:
		do {
			if ((LA(1)==COMA)) {
				match(COMA);
				param_stat();
			}
			else {
				break _loop51;
			}
			
		} while (true);
		}
	}
	
	public final void param_stat() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case ID:
		{
			match(ID);
			{
			switch ( LA(1)) {
			case CORCHETE_ABRIR:
			{
				match(CORCHETE_ABRIR);
				match(NUM_INTEGER);
				match(CORCHETE_CERRAR);
				break;
			}
			case COMA:
			case PARENTESIS_CERRAR:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			break;
		}
		case CADENA:
		{
			match(CADENA);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void sentencia() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case PARENTESIS_ABRIR:
		case NEGACION:
		{
			{
			{
			switch ( LA(1)) {
			case NEGACION:
			{
				match(NEGACION);
				break;
			}
			case PARENTESIS_ABRIR:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			match(PARENTESIS_ABRIR);
			sentencia();
			match(PARENTESIS_CERRAR);
			}
			break;
		}
		case NUM_REAL:
		case NUM_INTEGER:
		case ID:
		case CADENA:
		case MENOS:
		{
			comp();
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void comp() throws RecognitionException, TokenStreamException {
		
		
		expr();
		comparacion();
		expr();
	}
	
	public final void sentencia_cond() throws RecognitionException, TokenStreamException {
		
		
		match(PARENTESIS_ABRIR);
		comp();
		match(INTERROGACION);
		valor();
		match(COLON);
		valor();
		match(PARENTESIS_CERRAR);
	}
	
	public final void comparacion() throws RecognitionException, TokenStreamException {
		
		
		{
		switch ( LA(1)) {
		case MENOR:
		{
			match(MENOR);
			break;
		}
		case MAYOR:
		{
			match(MAYOR);
			break;
		}
		case NO_IGUAL:
		{
			match(NO_IGUAL);
			break;
		}
		case MENOR_IGUAL:
		{
			match(MENOR_IGUAL);
			break;
		}
		case MAYOR_IGUAL:
		{
			match(MAYOR_IGUAL);
			break;
		}
		case IGUAL:
		{
			match(IGUAL);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void anid_sentencia() throws RecognitionException, TokenStreamException {
		
		
		{
		switch ( LA(1)) {
		case OR:
		{
			match(OR);
			break;
		}
		case AND:
		{
			match(AND);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void operation() throws RecognitionException, TokenStreamException {
		
		
		{
		switch ( LA(1)) {
		case MAS:
		{
			match(MAS);
			break;
		}
		case MENOS:
		{
			match(MENOS);
			break;
		}
		case POR:
		{
			match(POR);
			break;
		}
		case DIV:
		{
			match(DIV);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void tipo() throws RecognitionException, TokenStreamException {
		
		
		{
		switch ( LA(1)) {
		case CHAR:
		{
			match(CHAR);
			break;
		}
		case VOID:
		{
			match(VOID);
			break;
		}
		case INT:
		{
			match(INT);
			break;
		}
		case FLOAT:
		{
			match(FLOAT);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void params_def() throws RecognitionException, TokenStreamException {
		
		
		def_par();
		{
		_loop95:
		do {
			if ((LA(1)==COMA)) {
				match(COMA);
				def_par();
			}
			else {
				break _loop95;
			}
			
		} while (true);
		}
	}
	
	public final void def_par() throws RecognitionException, TokenStreamException {
		
		
		tipo();
		{
		switch ( LA(1)) {
		case ASTERISCO:
		{
			match(ASTERISCO);
			break;
		}
		case ID:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(ID);
		{
		switch ( LA(1)) {
		case CORCHETE_ABRIR:
		{
			match(CORCHETE_ABRIR);
			match(CORCHETE_CERRAR);
			break;
		}
		case EOF:
		case COMA:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	
	public static final String[] _tokenNames = {
		"<0>",
		"EOF",
		"<2>",
		"NULL_TREE_LOOKAHEAD",
		"NUM_REAL",
		"NUM_INTEGER",
		"CARACTER",
		"\"int\"",
		"\"char\"",
		"\"void\"",
		"\"float\"",
		"\"if\"",
		"\"while\"",
		"\"break\"",
		"\"for\"",
		"NUEVA_LINEA",
		"BLANCO",
		"DIGITO",
		"NUMERO",
		"LETRA",
		"ID",
		"CADENA",
		"INTERROGACION",
		"COMILLAS",
		"PERCENT",
		"PUNTO",
		"COLON",
		"SEMICOLON",
		"COMA",
		"ASIGNACION",
		"PARENTESIS_ABRIR",
		"PARENTESIS_CERRAR",
		"LLAVE_ABRIR",
		"LLAVE_CERRAR",
		"CORCHETE_ABRIR",
		"CORCHETE_CERRAR",
		"MENOR",
		"MAYOR",
		"NEGACION",
		"NO_IGUAL",
		"MENOR_IGUAL",
		"MAYOR_IGUAL",
		"IGUAL",
		"AMP",
		"MAS",
		"MENOS",
		"POR",
		"DIV",
		"OR",
		"AND",
		"INC",
		"DEC",
		"REFERENCIA",
		"COMENTARIO",
		"ASTERISCO"
	};
	
	private static final long[] mk_tokenSet_0() {
		long[] data = { 1080704L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
	private static final long[] mk_tokenSet_1() {
		long[] data = { 35460326883376L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
	private static final long[] mk_tokenSet_2() {
		long[] data = { 272611241099312L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
	private static final long[] mk_tokenSet_3() {
		long[] data = { 272613388582960L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
	private static final long[] mk_tokenSet_4() {
		long[] data = { 35184375234608L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
	private static final long[] mk_tokenSet_5() {
		long[] data = { 272336363192368L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5());
	private static final long[] mk_tokenSet_6() {
		long[] data = { 35471198551474L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_6 = new BitSet(mk_tokenSet_6());
	private static final long[] mk_tokenSet_7() {
		long[] data = { 263884001771568L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_7 = new BitSet(mk_tokenSet_7());
	private static final long[] mk_tokenSet_8() {
		long[] data = { 264169617128882L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_8 = new BitSet(mk_tokenSet_8());
	private static final long[] mk_tokenSet_9() {
		long[] data = { 1116763576074272L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_9 = new BitSet(mk_tokenSet_9());
	private static final long[] mk_tokenSet_10() {
		long[] data = { 1117051342060978L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_10 = new BitSet(mk_tokenSet_10());
	private static final long[] mk_tokenSet_11() {
		long[] data = { 1116762502332416L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_11 = new BitSet(mk_tokenSet_11());
	private static final long[] mk_tokenSet_12() {
		long[] data = { 879900423650738L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_12 = new BitSet(mk_tokenSet_12());
	
	}
